package com.turnengine.client.global.game.command;

import com.javabi.command.IExecutableCommand;
import com.javabi.command.IExecutableCommandResponse;
import com.javabi.command.serializer.AbstractCommandDataSerializer;
import com.javabi.common.io.data.IDataReader;
import com.javabi.common.io.data.IDataWriter;
import com.turnengine.client.global.game.bean.GameDefinitionSerializer;
import com.turnengine.client.global.game.bean.IGameDefinition;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * The Get Game Definitions Data Serializer.
 */
public class GetGameDefinitionsDataSerializer extends AbstractCommandDataSerializer<List<IGameDefinition>> implements IGetGameDefinitionsDataSerializer {

	/**
	 * Creates a new Get Game Definitions Data Serializer.
	 */
	public GetGameDefinitionsDataSerializer() {
		super(GetGameDefinitions.COMMAND_ID);
	}

	@Override
	public List<IGameDefinition> readReturnValue(IDataReader reader) throws IOException {
		List<IGameDefinition> value = reader.readObjectCollection(new ArrayList<IGameDefinition>(), true, false, new GameDefinitionSerializer());
		return value;
	}

	@Override
	public void writeReturnValue(IDataWriter writer, List<IGameDefinition> value) throws IOException {
		writer.writeObjectCollection(value, true, false, new GameDefinitionSerializer());
	}

	@Override
	public IExecutableCommand<List<IGameDefinition>> readRequest(IDataReader reader) throws IOException {

		// Read fields

		// Create object
		GetGameDefinitions object = new GetGameDefinitions();
		return object;
	}

	@Override
	public void writeRequest(IDataWriter writer, IExecutableCommand<List<IGameDefinition>> argument) throws IOException {
		GetGameDefinitions object = (GetGameDefinitions) argument;

		// Get fields

		// Write fields
	}

	@Override
	public IExecutableCommandResponse<List<IGameDefinition>> newResponse() {
		return new GetGameDefinitionsResponse();
	}
}
